<script setup>
import Login from "@/view/Login.vue";
import {useCounterStore} from "@/assets/counter-index.js";

const gs = useCounterStore()


const token = localStorage.getItem("token")
if (token){
  gs.isLogin = true;
  gs.token = token;
}

// 退出登录
const logout = ()=>{
  localStorage.removeItem("token");
  gs.isLogin = false;
}
</script>

<template>
  <div v-if="gs.isLogin">

    <div class="top">
      <span>
        <img src="/logo.png" alt="" style="height: 40px;">
        高缦智慧系统
      </span>
      <span >
        <el-button plain @click="logout">退出登录</el-button>
      </span>
    </div>

    <div class="content">

      <div class="content-left" style="height: calc(100vh - 80px);">
        <el-menu router default-active="/" style="height: 100%;">
          <el-menu-item index="/"><el-icon><HotWater /></el-icon>欢迎页</el-menu-item>
          <el-menu-item index="/student"><el-icon><User /></el-icon>学员管理</el-menu-item>
          <el-menu-item index="/dormitory"><el-icon><School /></el-icon>寝室管理</el-menu-item>
          <el-menu-item index="3"><el-icon><Reading /></el-icon>课程管理</el-menu-item>
          <el-menu-item index="4"><el-icon><House /></el-icon>食堂管理</el-menu-item>
        </el-menu>
      </div>

      <div class="content-right">
          <RouterView />
      </div>

    </div>

  </div>
  <div v-if="!gs.isLogin">
    <Login />
  </div>
</template>

<style scoped>
  .top{
    height: 50px;
    padding: 5px 20px;
    box-sizing: border-box;
    border-bottom: 1px solid #bfbfbf;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .content{
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
  }
  .content-left{
    width: 130px;
  }
  .content-right{
    flex-grow: 1;
    padding: 10px;
    box-sizing: border-box;
  }
</style>
